@charset "utf-8";
//-----------------------------------------------------
// table scss
//-----------------------------------------------------

// thanks:https://github.com/thomas-mcdonald/bootstrap-sass/blob/master/vendor/assets/stylesheets/bootstrap/_tables.scss

// 变量
//---------------------------------
$zebraLte8:                      false !default; //斑马线效果是否支持ie8，如果支持请在tr里面添加class odd
$tableBgColor:                   transparent !default; // overall background-color
$tableBgColorEven:               #f9f9f9 !default; // for striping zebra
$tableBgColorHover:              #e9f5ff !default; // for hover
$tableBorderColor:               $gray !default; // table and cell border
$tableThBgColor:                 #f4f4f4 !default;//默认th背景色
$tableColThWidth:                80px !default;//默认左边第一栏为th表格的th宽度
$tableCellPadding:               8px !default;//单元格的padding
$tableRadius:                    $baseRadius !default;//圆角大小
$tableResetSwitch:               true !default;//是否已经有了table的重置border-collapse: collapse;border-spacing: 0;

//各个table开关设置
$tableBorderSwitch:              true !default;
$tableListSwitch:                false !default;
$tableColThSwitch:               false !default;
$tableRadiusSwitch:              false !default;
$tableLineSwitch:                false !default;
$tableStripedSwitch:             false !default;
$tableHoverSwitch:               false !default;
$tableCondensedSwitch:           false !default;
$tableStatusSwitch:              false !default;


//table mixin
//---------------------------------
@mixin table-radius($radius: $tableRadius){
  border-collapse: separate; // Done so we can round those corners!
  @if $lte7 {
    *border-collapse: collapse; // IE7 can't round corners anyway
  }
  border-radius: $radius;
  // For first th/td in the first row in the first thead or tbody
  thead:first-child tr:first-child > th:first-child,
  tbody:first-child tr:first-child > td:first-child,
  tbody:first-child tr:first-child > th:first-child {
    border-top-left-radius: $radius;
  }
  // For last th/td in the first row in the first thead or tbody
  thead:first-child tr:first-child > th:last-child,
  tbody:first-child tr:first-child > td:last-child,
  tbody:first-child tr:first-child > th:last-child {
    border-top-right-radius: $radius;
  }
  // For first th/td (can be either) in the last row in the last thead, tbody, and tfoot
  thead:last-child tr:last-child > th:first-child,
  tbody:last-child tr:last-child > td:first-child,
  tbody:last-child tr:last-child > th:first-child,
  tfoot:last-child tr:last-child > td:first-child,
  tfoot:last-child tr:last-child > th:first-child {
    border-bottom-left-radius: $radius;
  }
  // For last th/td (can be either) in the last row in the last thead, tbody, and tfoot
  thead:last-child tr:last-child > th:last-child,
  tbody:last-child tr:last-child > td:last-child,
  tbody:last-child tr:last-child > th:last-child,
  tfoot:last-child tr:last-child > td:last-child,
  tfoot:last-child tr:last-child > th:last-child {
    border-bottom-right-radius: $radius;
  }

  // Clear border-radius for first and last td in the last row in the last tbody for table with tfoot
  tfoot + tbody:last-child tr:last-child td:first-child {
    border-bottom-left-radius: $radius;
  }
  tfoot + tbody:last-child tr:last-child td:last-child {
    border-bottom-right-radius: $radius;
  }

  // Special fixes to round the left border on the first td/th
  caption + thead tr:first-child th:first-child,
  caption + tbody tr:first-child td:first-child,
  colgroup + thead tr:first-child th:first-child,
  colgroup + tbody tr:first-child td:first-child {
    border-top-left-radius: $radius;
  }
  caption + thead tr:first-child th:last-child,
  caption + tbody tr:first-child td:last-child,
  colgroup + thead tr:first-child th:last-child,
  colgroup + tbody tr:first-child td:last-child {
    border-top-right-radius: $radius;
  }
}

@mixin table-border($borderColor:$tableBorderColor){
  th,
  td {
    border: 1px solid $borderColor;
  }
}

@mixin zebra-stripe($even: $tableBgColorEven){
  tbody {
    > tr:nth-child(even) > td{
      background-color: $even;
    } 
  }
  @if $zebraLte8 {
    tr.even td{
      background-color: $even;
    }
  }
}

@mixin tr-hover($hover: $tableBgColorHover){
  tbody {
    tr:hover > td{
      background-color: $hover;
    }
  }
}

@mixin table-thead($thBgColor:$primary,$thTextColor:$white){
  th{
    background-color: $thBgColor;
    color:$thTextColor;
    font-weight: normal;
  }
}


//table class
//---------------------------------
.table {
  width: 100%;
  margin-bottom: $baseGap;

  @if not $tableResetSwitch{
    border-collapse: collapse;
    border-spacing: 0;
  }
  th,td{
    padding: $tableCellPadding;
  }
  thead th{
    text-align: left;
  }
}

.table-fixed{
  table-layout: fixed;
}

@if $tableBorderSwitch{
  .table-border{
    @include table-border;
  }
}

@if $tableListSwitch{
  .table-list{
    @include table-thead;
    td{
      border-bottom:1px dashed $tableBorderColor;
    }
    @include zebra-stripe;
    @include tr-hover;
  }  
}

@if $tableCondensedSwitch{
  .table-condensed {
    th,
    td {
      padding: 4px 5px;
    }
  }  
}

@if $tableLineSwitch{
  .table-line{
    th,td{
      border-top:1px solid $tableBorderColor;
    }
    thead:first-child tr:first-child th,
    thead:first-child tr:first-child td {
      border-top: 0;
    }
    @if $lte7 {
      _border-bottom:1px solid $tableBorderColor;
    }
  }  
}

@if $tableRadiusSwitch{
  .table-radius {
    border-top:1px solid $tableBorderColor;
    border-left:1px solid $tableBorderColor;
    th,td{
      border-right:1px solid $tableBorderColor;
      border-bottom:1px solid $tableBorderColor;
    }
    @include table-radius($tableRadius);
  }  
}

@if $tableStripedSwitch{
  .table-striped {
    @include zebra-stripe($tableBgColorEven);
  }  
}

@if $tableHoverSwitch{
  .table-hover {
    @include tr-hover($tableBgColorHover);
  }  
}

@if $tableColThSwitch{
  .table-col-th{
    @include table-border;
    th{
      background-color: $tableThBgColor;
      width: $tableColThWidth;
      vertical-align: middle;
    }
  }  
}

// TABLE BACKGROUNDS
// Exact selectors below required to override .table-striped
//---------------------------------
@if $tableStatusSwitch {
  .table tr {
    &.tr-success td {
      background-color: nth($successColor,2);
    }
    &.tr-error td {
      background-color: nth($errorColor,2);
    }
    &.tr-warning td {
      background-color: nth($warningColor,2);
    }
    &.tr-info td {
      background-color: nth($infoColor,2);
    }
  }

  // Hover states for .table-hover
  .table-hover tr {
    &.tr-success:hover td {
      background-color: darken(nth($successColor,2), 5%);
    }
    &.tr-error:hover td {
      background-color: darken(nth($errorColor,2), 5%);
    }
    &.tr-warning:hover td {
      background-color: darken(nth($warningColor,2), 5%);
    }
    &.tr-info:hover td {
      background-color: darken(nth($infoColor,2), 5%);
    }
  }
}